package main

import "fmt"

/*
	ping

pings 只能发送数据，不能接收数据
*/
func ping(pings chan<- string, msg string) {
	pings <- msg
}

/*
	pong

pings 只能接收数据，不能发送数据
pongs 只能发送数据，不能接收数据
*/
func pong(pings <-chan string, pongs chan<- string) {
	msg := <-pings
	pongs <- msg
}

func main() {
	pings := make(chan string, 1)
	pongs := make(chan string, 1)

	ping(pings, "passed message")

	pong(pings, pongs)
	fmt.Println(<-pongs)
}
